import hashlib
import os
from django.core.mail import EmailMultiAlternatives
from django.conf import settings

h = hashlib.sha256()
s = 'fudan'
print(h)
s +='mysite'
print(s)
h.update(s.encode())
print(h)
print(h.hexdigest())
print(type(h.hexdigest()))


# 发送邮件
os.environ["DJANGO_SETTINGS_MODULE"] = 'login_project.settings'

code = 'dasdasdasdasdja'
subject = '来自薛夏磊的注册确认邮件'
text_content = '感谢注册www.xialeixue.github.io，这里是薛夏磊的个人主页和博客，专注于Python、Django和数据挖掘技术的分享！如果你看到这条消息，说明你的邮箱服务器不提供HTML链接功能，请联系管理员！'
html_content = '''<p>感谢注册<a href="http://{}/confirm/?code={}" </a>，这里是薛夏磊的个人主页和博客，专注于Python、Django和数据挖掘技术的分享！</p>'''
msg = EmailMultiAlternatives(subject, text_content, settings.EMAIL_HOST_USER, ['xialeixue@hotmail.com'])
msg.attach_alternative(html_content, 'text/html')
msg.send()



